#ifndef _STRATEGY_HH_
#define _STRATEGY_HH_
#include "Bfs.hh"
#include "State.h"
#include "Order.h"
#include "MI5.hh"
#include "Planif.hh"

/// Strategy parameters
const double explorationw = 1;
const double foodw = 2;
const double myhillw = 8;
const double friendw = 1;
const double hillw = 4;


/// set potentials for attraction/repulsion of ants
void set_potentials(State & state);


struct action_plan_t
{
  std::vector<Option> options;
  std::vector<unsigned> directions;
  std::vector<double> bonuses;
  
  void reset(void)
  {
    options.clear();
    directions.clear();
  }

  void proposeTarget(uLocation from, uLocation to, double cost, unsigned direction, double bonus = 1)
  {
    options.push_back(Option(from,to,cost));
    directions.push_back(direction);
    bonuses.push_back(bonus);
  }

  void execute_plan(State & state, Order & order, bool minimize = true)
  {
    std::set<std::pair<uLocation,uLocation> > plan(get_an_optimal_plan(options, minimize));

    bug << "optimal plan" << std::endl;
    
    for(unsigned i=0; i!=options.size(); ++i)
      if(plan.count(std::pair<uLocation,uLocation>(options[i].from,options[i].to)))
	{
	  uLocation to = state.grid().getLocation(options[i].from,directions[i]);
	  order.proposeMove(state, options[i].from, to, directions[i], bonuses[i]);
#if DEBUG
 	  dump(bug.file,state.grid(),options[i]);
#endif
	}
    reset();
  }
  
};


/// assign closest ants to known food
void assign_to_food(State & state, Order & order);

/// assign some ants to corner of hive
void assign_to_guard(State & state, Order & order);

/// assign some ants to attack enemy hills
void assign_to_raze_hills(State & state, Order & order);




#endif /* _STRATEGY_HH_ */
